package evaluation;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;



public class Evaluate extends Thread{

	/**
	 * @param args
	 */
	
	String word ;
	static String file;
	public static void main(String[] args) {
		
		//Evaluate e = new Evaluate();
		Evaluate t = new Evaluate();
		file = args[0];
		t.start();
	
	}

	public void eval(ArrayList<String> words) throws InterruptedException {
		//BingDistanceCaculator b = new BingDistanceCaculator();
		for(String s: words){
			double d = BingDistanceCaculator.getGoogleDistance(word, s);
			sleep(1000);
			//System.out.println(s + "\t" + d);
		}
	}

	private ArrayList<String> fetchWords(String file) {
		ArrayList<String> list = new ArrayList<String>();
		try {
			BufferedReader br = new BufferedReader(new FileReader(file));
			String line;
			
			while((line = br.readLine()) != null){
				String[] str = line.split("%");
				
				list.add(str[1]);
			}
			
			word = list.get(0);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return list;
	}

	@Override
	public void run() {
		
		try {
			ArrayList<String> words = fetchWords(file);
			eval(words);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
